﻿/*
* Sale_order_implement.cs
*
* 功 能： N/A
* 类 名： Sale_order_implement
*
* Ver    变更日期             负责人     变更内容
* ───────────────────────────────────
* V1.0  2016-03-08 08:53:11    黄润伟    
*
* Copyright © 2015 www.xhdcrm.com All rights reserved.
*┌──────────────────────────────────┐
*│　版权所有：小黄豆                      　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using XHD.DBUtility;//Please add references
namespace XHD.DAL
{
    /// <summary>
	/// 数据访问类:Sale_order_implement
	/// </summary>
	public partial class Sale_order_implement
    {
        public Sale_order_implement()
        { }

        #region  BasicMethod
        
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XHD.Model.Sale_order_implement model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Sale_order_implement(");
            strSql.Append("id,xhs_code,xhs_batch,xhs_website,xhs_nickname,xhs_guangzhu,xhs_fun,xhs_hudong,xhs_state,xhs_remark,xhs_contenttype,xhs_articlelink,xhs_approve,xhs_modify1,xhs_publishplan,xhs_notelink,xhs_proofread,create_id,create_time)");
            strSql.Append(" values (");
            strSql.Append("@id,@xhs_code,@xhs_batch,@xhs_website,@xhs_nickname,@xhs_guangzhu,@xhs_fun,@xhs_hudong,@xhs_state,@xhs_remark,@xhs_contenttype,@xhs_articlelink,@xhs_approve,@xhs_modify1,@xhs_publishplan,@xhs_notelink,@xhs_proofread,@create_id,@create_time)");
            SqlParameter[] parameters = {
                    new SqlParameter( "@id", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_code", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_batch", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_website", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_nickname", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_guangzhu", SqlDbType.Int,4),
                    new SqlParameter( "@xhs_fun", SqlDbType.Int,4),
                    new SqlParameter( "@xhs_hudong", SqlDbType.Int,4),
                    new SqlParameter( "@xhs_state", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_remark", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_contenttype", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_articlelink", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_approve", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_modify1", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_publishplan", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_notelink", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_proofread", SqlDbType.Int,4),
                    new SqlParameter( "@create_id", SqlDbType.VarChar,500),
                    new SqlParameter( "@create_time", SqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.xhs_code;
            parameters[2].Value = model.xhs_batch;
            parameters[3].Value = model.xhs_website;
            parameters[4].Value = model.xhs_nickname;
            parameters[5].Value = model.xhs_guangzhu;
            parameters[6].Value = model.xhs_fun;
            parameters[7].Value = model.xhs_hudong;
            parameters[8].Value = model.xhs_state;
            parameters[9].Value = model.xhs_remark;
            parameters[10].Value = model.xhs_contenttype;
            parameters[11].Value = model.xhs_articlelink;
            parameters[12].Value = model.xhs_approve;
            parameters[13].Value = model.xhs_modify1;
            parameters[14].Value = model.xhs_publishplan;
            parameters[15].Value = model.xhs_notelink;
            parameters[16].Value = model.xhs_proofread;
            parameters[17].Value = model.create_id;
            parameters[18].Value = model.create_time;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(XHD.Model.Sale_order_implement model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update Sale_order_implement set ");
            strSql.Append("xhs_code = @xhs_code,");
            strSql.Append("xhs_batch = @xhs_batch,");
            strSql.Append("xhs_website = @xhs_website,");
            strSql.Append("xhs_nickname = @xhs_nickname,");
            strSql.Append("xhs_guangzhu = @xhs_guangzhu,");
            strSql.Append("xhs_fun = @xhs_fun,");
            strSql.Append("xhs_hudong = @xhs_hudong,");
            strSql.Append("xhs_state = @xhs_state,");
            strSql.Append("xhs_remark = @xhs_remark,");
            strSql.Append("xhs_contenttype = @xhs_contenttype,");
            strSql.Append("xhs_articlelink = @xhs_articlelink,");
            strSql.Append("xhs_approve = @xhs_approve,");
            strSql.Append("xhs_modify1 = @xhs_modify1,");
            strSql.Append("xhs_publishplan = @xhs_publishplan,");
            strSql.Append("xhs_notelink = @xhs_notelink,");
            strSql.Append("xhs_proofread = @xhs_proofread,");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters = {
                    new SqlParameter( "@xhs_code", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_batch", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_website", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_nickname", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_guangzhu", SqlDbType.Int,4),
                    new SqlParameter( "@xhs_fun", SqlDbType.Int,4),
                    new SqlParameter( "@xhs_hudong", SqlDbType.Int,4),
                    new SqlParameter( "@xhs_state", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_remark", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_contenttype", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_articlelink", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_approve", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_modify1", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_publishplan", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_notelink", SqlDbType.VarChar,500),
                    new SqlParameter( "@xhs_proofread", SqlDbType.Int,4),
                    new SqlParameter( "@id", SqlDbType.VarChar,500)
            };

            parameters[0].Value = model.xhs_code;
            parameters[1].Value = model.xhs_batch;
            parameters[2].Value = model.xhs_website;
            parameters[3].Value = model.xhs_nickname;
            parameters[4].Value = model.xhs_guangzhu;
            parameters[5].Value = model.xhs_fun;
            parameters[6].Value = model.xhs_hudong;
            parameters[7].Value = model.xhs_state;
            parameters[8].Value = model.xhs_remark;
            parameters[9].Value = model.xhs_contenttype;
            parameters[10].Value = model.xhs_articlelink;
            parameters[11].Value = model.xhs_approve;
            parameters[12].Value = model.xhs_modify1;
            parameters[13].Value = model.xhs_publishplan;
            parameters[14].Value = model.xhs_notelink;
            parameters[15].Value = model.xhs_proofread;

            parameters[16].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string whereStr)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Sale_order_implement ");
            strSql.Append(" where "+whereStr);
           
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere, bool isAll = false )
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT  ");
            strSql.Append("Sale_order_implement.[id] ");
            strSql.Append(",Sale_order_implement.[xhs_code] ");
            strSql.Append(",Sale_order_implement.[xhs_batch] ");
            strSql.Append(",Sale_order_implement.[xhs_website] ");
            strSql.Append(",Sale_order_implement.[xhs_nickname] ");
            strSql.Append(",Sale_order_implement.[xhs_guangzhu] ");
            strSql.Append(",Sale_order_implement.[xhs_fun] ");
            strSql.Append(",Sale_order_implement.[xhs_hudong] ");
            strSql.Append(",Sale_order_implement.[xhs_state] ");
            strSql.Append(",Sale_order_implement.[xhs_remark] ");
            strSql.Append(",Sale_order_implement.[xhs_contenttype] ");
            strSql.Append(",Sale_order_implement.[xhs_articlelink] ");
            strSql.Append(",Sale_order_implement.[xhs_approve] ");
            strSql.Append(",Sale_order_implement.[xhs_modify1] ");
            strSql.Append(",Sale_order_implement.[xhs_publishplan] ");
            strSql.Append(",Sale_order_implement.[xhs_notelink] ");
            strSql.Append(",Sale_order_implement.[xhs_proofread] ");
            strSql.Append(",Sale_order_implement.[create_id] ");
            strSql.Append(",Sale_order_implement.[create_time] ");

            strSql.Append(" FROM [dbo].[Sale_order_implement] ");

            if (!isAll) strSql.Append("  INNER JOIN CRM_Customer ON CRM_Customer.xhs_code = Sale_order_implement.xhs_code ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder, bool isAll = false)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append("Sale_order_implement.[id] ");
            strSql.Append(",Sale_order_implement.[xhs_code] ");
            strSql.Append(",Sale_order_implement.[xhs_batch] ");
            strSql.Append(",Sale_order_implement.[xhs_website] ");
            strSql.Append(",Sale_order_implement.[xhs_nickname] ");
            strSql.Append(",Sale_order_implement.[xhs_guangzhu] ");
            strSql.Append(",Sale_order_implement.[xhs_fun] ");
            strSql.Append(",Sale_order_implement.[xhs_hudong] ");
            strSql.Append(",Sale_order_implement.[xhs_state] ");
            strSql.Append(",Sale_order_implement.[xhs_remark] ");
            strSql.Append(",Sale_order_implement.[xhs_contenttype] ");
            strSql.Append(",Sale_order_implement.[xhs_articlelink] ");
            strSql.Append(",Sale_order_implement.[xhs_approve] ");
            strSql.Append(",Sale_order_implement.[xhs_modify1] ");
            strSql.Append(",Sale_order_implement.[xhs_publishplan] ");
            strSql.Append(",Sale_order_implement.[xhs_notelink] ");
            strSql.Append(",Sale_order_implement.[xhs_proofread] ");
            strSql.Append(",Sale_order_implement.[create_id] ");
            strSql.Append(",Sale_order_implement.[create_time] ");

            strSql.Append(" FROM [dbo].[Sale_order_implement] ");
            if (!isAll) strSql.Append(" INNER JOIN CRM_Customer ON CRM_Customer.xhs_code = Sale_order_implement.xhs_code ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }
        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

